package cn.itcast.controller;

import cn.itcast.bean.QuotRes;
import cn.itcast.service.QuotService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

@RestController  //包含Controller和ResponseBody(表示返回的数据以json格式进行返回)注解，
@RequestMapping("quot")
public class QuotController {

    @Autowired
    QuotService quotService;

    /**
     * 国内指数查询
     */
    @RequestMapping("index/all")
    public QuotRes indexQuery() throws SQLException {
        return quotService.indexQuery();
    }


    //板块指数
    @RequestMapping("sector/all")
    public QuotRes sectorQuery() throws SQLException {
        return quotService.sectorQuery();
    }


    //外盘指数
    @RequestMapping("/external/index")
    public QuotRes externalQuery() throws SQLException {
        return quotService.externalQuery();
    }


    //涨幅榜
    @RequestMapping("stock/increase")
    public QuotRes increaseQuery() throws SQLException{
        return quotService.increaseQuery();
    }

    //涨停跌停数
    @RequestMapping("stock/updown/count")
    public JSONObject upDownCount() throws SQLException {
        return quotService.upDownCount();
    }

    //T日与T-1日成交量对比
    @RequestMapping("stock/tradevol")
    public JSONObject compareTradeTol() throws SQLException {
        return quotService.compareTradeVol();
    }

    //个股涨跌幅度查询
    @RequestMapping("stock/updown")
    public QuotRes increaseRangeQuery() throws SQLException {
        return quotService.increaseRangeQuery();
    }


    //个股分时列表行情
    @RequestMapping("stock/all")
    public QuotRes stockAll() throws SQLException {
        return quotService.stockAll();
    }

    //个股模糊查询
    @RequestMapping("stock/search")
    public QuotRes searchCode(String searchStr) throws SQLException {
        return quotService.searchCode(searchStr);
    }


    /**
     * 个股分时详细行情
     * 查询单个个股的分时行情数据，查询时间周期是T日开盘到当前时间
     */
    @RequestMapping("stock/screen/time-sharing")
    public QuotRes timeSharingQuery(String code) throws SQLException {
        return quotService.timeSharingQuery(code);
    }


    /**
     * 个股日k
     */
    @RequestMapping("stock/screen/dkline")
    public QuotRes dklineQuery(String code) throws SQLException {
        return quotService.dklineQuery(code);
    }


    //个股最新分时行情数据-制定个股代码下的最新一条数据
    @RequestMapping("stock/screen/second/detail")
    public JSONObject stockMinDetail(String code) throws SQLException {
        return quotService.stockMinDetail(code);
    }


    //秒级数据查询--查询当前分钟内的秒级数据
    @RequestMapping("stock/screen/second")
    public QuotRes stockSecQuery(String code) throws SQLException {
        return quotService.stockSecQuery(code);
    }


    //个股主营业务描述
    @RequestMapping("stock/describe")
    public JSONObject stockDesc(String code) throws SQLException {
        return quotService.stockDesc(code);
    }
}
